import re
from playwright.sync_api import Playwright, sync_playwright, expect


def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()
    page.goto("https://auth.hexcloud.cn/heytea/login?login_challenge=22f40e0a138c4c3da8e8e0f12b852f5f")
    page.goto("https://auth.hexcloud.cn/heytea/login?code=f9fef449d93e3f249b814dffe6032225&state=type:login,loginChallenge:,partnerId:4206763836826861569")
    page.get_by_placeholder("请输入账号").click()
    page.get_by_placeholder("请输入账号").fill("J21013414")
    page.get_by_placeholder("请输入密码").click()
    page.get_by_placeholder("请输入密码").fill("J@21013414")
    page.get_by_role("button", name="登录").click()
    page.goto("https://partner-store.heytea.com/ids-basic/index")
    page.get_by_role("menuitem", name="报废单 ").get_by_role("link").click()
    page.get_by_placeholder("Start Time").click()
    page.get_by_title("-02-11").locator("div").click()
    page.get_by_title("-02-18").locator("div").click()
    page.locator("#react-select-2--value div").filter(has_text="全部状态").click()
    page.get_by_role("option", name="已提交").click()
    page.get_by_role("button", name="查询").click()
    page.close()

    # ---------------------
    context.close()
    browser.close()


with sync_playwright() as playwright:
    run(playwright)
